package com.kujawnode.manager;

import com.kujawnode.model.TUser;
import jakarta.annotation.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.List;

/**
 * @version 1.0
 * @Author kujaw
 * @Date 2025/7/17 18:27
 * @注释
 */
@Component
public class RedisManager {

    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    public Object getValue(String key){
        // return redisTemplate.opsForValue().get(key);
        return redisTemplate.opsForList().range(key, 0, -1);
    }

    public <T> Object setValue(String key, Collection<T> data){
        // redisTemplate.opsForValue().set(key, data); //string类型
        Object[] t = new Object[data.size()];
        data.toArray(t);
        return redisTemplate.opsForList().leftPushAll(key,t);
    }

}
